package com.mayflygeek.mayflyask.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mayflygeek.mayflyask.entity.User;

/**
 * @author 蝈蝈 
 * @email guodefu909@126.com
 * @team 蜉蝣极客
 * @link www.mayflygeek.com
 * 将登录用户信息保存在ThreadLocal中，方便获取
 */
public class UserUtils {
	
	private static Logger log = LoggerFactory.getLogger(UserUtils.class);
	
	private static ThreadLocal<User> threadLocal = new ThreadLocal<>();
	
	private UserUtils() {
	}
	
	public static void setSessionUser(User user) {
		log.info("UserUtils.setSessionUser");
		threadLocal.set(user);
    }  
  
    public static User getSessionUser() {  
    	log.info("UserUtils.getSessionUser");
    	return threadLocal.get();
    }  

}
